#include "levelchoose.h"
#include <QPushButton>
#include <QMenuBar>
#include <QDebug>
levelchoose::levelchoose(QWidget *parent) : QMainWindow(parent)
{
    QMenuBar * bar = menuBar();
    setMenuBar(bar);
    QMenu * startMenu = bar->addMenu("开始");

    QAction * quit = startMenu->addAction("退出");
    connect(quit,&QAction::triggered,[=](){
        this->close();
    });
    QAction * back = startMenu->addAction("返回");
    connect(back,&QAction::triggered,[=](){
        emit this->levelsceneBack();
    });
    this->setFixedSize(800,600);
    int length = 0;
    int width = 0;
    int num = 0;
    QPushButton * easy = new QPushButton("简单",this);
    easy->resize(300,100);
    easy->move(this->width()*0.5-easy->width()*1,this->height()*0.15);
    connect(easy,&QPushButton::clicked,[=](){
        gamescene = new game(nullptr,9,9,10);
        this->hide();
        gamescene->show();
        connect(gamescene,&game::Backtomenu,this,[=](){
            emit this-> levelsceneBack();
            gamescene->close();
        });
    });
    QPushButton * medium = new QPushButton("中等",this);
    medium->resize(300,100);
    medium->move(this->width()*0.5-medium->width()*1,this->height()*0.35);
    connect(medium,&QPushButton::clicked,[=](){
        gamescene = new game(nullptr,16,16,40);
        this->hide();
        gamescene->show();
        connect(gamescene,&game::Backtomenu,this,[=](){
            emit this-> levelsceneBack();
            gamescene->close();
        });
    });
    QPushButton * hard = new QPushButton("困难",this);
    hard->resize(300,100);
    hard->move(this->width()*0.5-hard->width()*1,this->height()*0.55);
    connect(hard,&QPushButton::clicked,[=](){
        gamescene = new game(nullptr,30,16,99);
        this->hide();
        gamescene->show();
        connect(gamescene,&game::Backtomenu,this,[=](){
            emit this-> levelsceneBack();
            gamescene->close();
        });
    });

    QPushButton * customize = new QPushButton("自定义",this);
    customize->resize(300,100);
    customize->move(this->width()*0.5-customize->width()*1,this->height()*0.75);

}
